package com.wlyuan.index.domain.source.adapter;

import com.wlyuan.finance.dto.IndexBillEventDTO;
import com.wlyuan.index.api.dto.waybill.BillIndexDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

/**
 * 运单事件详情（对应运输服务的 WaybillEventDTO类）
 *
 * @author liuqingqing
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BillAdapter extends BillIndexDTO {
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Relation {
        private Integer status;
        private Long tenantId;
    }

    @Mapper
    public interface Assembler {
        void assemble(@MappingTarget BillIndexDTO bill, BillIndexDTO source);

        BillIndexDTO translate(IndexBillEventDTO source);
    }

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    public BillAdapter(BillIndexDTO index) {
        ASSEMBLER.assemble(this, index);
    }

    public static BillIndexDTO translate(IndexBillEventDTO source) {
        return ASSEMBLER.translate(source);
    }
}
